﻿using MetroDataQuery.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MetroDataApi.Models
{
    public class SinglePointRecentChanges
    {
        public static IEnumerable<result> RecentChanges(int prjId, string ptName, string queryType = "", string startTime = "", string endTime = "")
        {
            var list = new List<result>();
            switch (queryType)
            {

                default: //默认取最近10次
                    {
                        return MonitorPointsQuery.GetSinglePointsByName(prjId, ptName, "", "", 10).
                            Select(p => new result()
                            {
                                name = p.Name,
                                time = p.DateTime.Value.ToString("yyyy-MM-dd"),
                                value = p.Value.Value
                            });
                    }
                case "custom":
                    {
                        return MonitorPointsQuery.GetSinglePointsByName(prjId, ptName, startTime, endTime).Select(p => new result()
                        {
                            name = p.Name,
                            time = p.DateTime.Value.ToString("yyyy-MM-dd"),
                            value = p.Value.Value
                        });
                    }
            }
        }

    }
}